/**
 * @projectName demo-master
 * @fileName TestController.java
 * @packageName org.example.nacos.dicsovery.controller
 * @author xaoyaoyao
 * @date 2021/3/29 16:51
 * @version V1.0
 * @copyright (c) 2021, xaoyaoyao@aliyun.com All Rights Reserved.
 */
package org.example.nacos.dicsovery.controller;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @className TestController
 * @description
 * @author xaoyaoyao
 * @date 2021/3/29 16:51
 */
@Controller
@RequestMapping("discovery")
public class TestController {

	@NacosInjected
	private NamingService namingService;

	@RequestMapping(value = "/get", method = RequestMethod.GET)
	@ResponseBody
	public List<Instance> get(@RequestParam String serviceName) throws NacosException {
		return namingService.getAllInstances(serviceName);
	}
}
